using UnityEngine;
using System.Collections;

/// \class  gkDestroyOnExitGameVolume
/// \brief  Component handling the object scrolling to go along with the current forward velocity
[AddComponentMenu("GK/Engine/Game/Scrolling/gkScrollingComponent")]
public class gkScrollingComponent : MonoBehaviour
{
	/// The scrolling Physic Component
	private gkPhysicComponent m_oScrollingPhysicComponent;
	
    /// The scrolling info
    private gkPhysicComponent m_rScrollingInfoPhysicComponent;

    /// \brief  Called just after the game begin to play
    void Start()
    {
        // Get the scrolling info
        m_rScrollingInfoPhysicComponent = GameObject.Find("ScrollingInfo").GetComponent<gkPhysicComponent>();
		
		// Create the scrolling physic component
		m_oScrollingPhysicComponent = gameObject.AddComponent<gkPhysicComponent>();
		
		// Set a velocity offset for the frame according to the global world scrolling speed
        m_oScrollingPhysicComponent.SetLinearVelocity(m_rScrollingInfoPhysicComponent.GetLinearVelocity());
    }

    /// \brief  Called each frame
    void Update()
    {
	    // Set a velocity offset for the frame according to the global world scrolling speed
        m_oScrollingPhysicComponent.SetLinearVelocity(m_rScrollingInfoPhysicComponent.GetLinearVelocity());
    }
}
